package com.sskj.market.presenter;

import com.lzy.okgo.model.Response;
import com.lzy.okrx2.adapter.FlowableBody;
import com.sskj.common.base.HttpData;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.lib.http.JsonConverter;
import com.sskj.market.bean.AddressBean;
import com.sskj.market.bean.ShopSearchBean;
import com.sskj.market.ui.activity.SearchActivity;

import java.util.ArrayList;
import java.util.List;

import io.reactivex.Flowable;


/**
 * @author Hey
 * Create at  2019/07/25
 */
public class SearchPresenter extends BasePresenter<SearchActivity> {

    public Flowable<List<ShopSearchBean.DataBean>> getSearchData(String page,String key_words, int category_id, boolean flag) {
        return httpService.getSearchData(page,key_words, category_id)
                .converter(new JsonConverter<HttpData<ShopSearchBean>>() {
                })
                .adapt(new FlowableBody<>())
                .map(shopSearchBeanHttpData -> shopSearchBeanHttpData.getData().getData())
                .onErrorReturnItem(new ArrayList<>());

    }
}
